﻿<phone:PhoneApplicationPage 
    x:Class="SST.Phone.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:ctb="clr-namespace:ChatTextBlockControl;assembly=ChatTextBlockControl"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:util="clr-namespace:SST.Phone.Util"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
    d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="{Binding ShowTray}">

    <UserControl.Resources>
        <util:UIImageConverter x:Key="imgConveter"/>
        <util:UIUriConverter x:Key="uriConverter"/>
        <util:UIDurationConverter x:Key="durationConverter"/>
        <util:UIRequesterCommentConverter x:Key="requesterCommentConverter"/>
        <util:UITrackTitleAndDurationConverter x:Key="titleAndDurationConverter"/>
        <util:UIVisibilityConverter x:Key="visibilityConverter"/>
    </UserControl.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
 
        <!--Panorama control-->
        <controls:Panorama x:Name="MainPanorama" Title="StreamingSoundtracks.com" SelectionChanged="Panorama_SelectionChanged">
            <controls:Panorama.Background>
                <ImageBrush ImageSource="PanoramaBackground.png"/>
            </controls:Panorama.Background>
 
            <!--Panorama now playing-->
            <controls:PanoramaItem Header="now playing">
                <ScrollViewer>
                    <StackPanel>
                        <Image Width="250" Height="250" Source="{Binding NowPlaying.Track.AlbumArt, Converter={StaticResource imgConveter}}" />
                        <HyperlinkButton FontSize="20" Style="{StaticResource HyperlinkButtonWrappingStyle}"
                            Content="{Binding NowPlaying.Track.Album}" TargetName="_blank"
                            NavigateUri="{Binding NowPlaying.Track.AlbumUrl, Converter={StaticResource uriConverter}}"/>
                        <TextBlock Text="{Binding NowPlaying.Track.Artist}"
                            Style="{StaticResource PhoneTextNormalStyle}"
                            HorizontalAlignment="Center" FontSize="20" TextWrapping="Wrap"/>

                        <TextBlock Text="{Binding Path=NowPlaying.Track.Title}"
                            Style="{StaticResource PhoneTextNormalStyle}"
                            HorizontalAlignment="Center" TextWrapping="Wrap" />
                        <TextBlock Text="{Binding Path=NowPlaying.Track.Duration, Converter={StaticResource durationConverter}}"
                            Style="{StaticResource PhoneTextSubtleStyle}"
                            HorizontalAlignment="Center" TextWrapping="Wrap" />
                    
                        <StackPanel Background="#FF000044" Margin="0,10,0,0">
                            <TextBlock Text="{Binding NowPlaying.Requester, StringFormat='Brought to you by \{0\}'}"
                                Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Center"/>
                            <TextBlock Text="{Binding NowPlaying.Comment, StringFormat='&quot;\{0\}&quot;'}"
                                Style="{StaticResource PhoneTextNormalStyle}" HorizontalAlignment="Center" TextWrapping="Wrap" MaxHeight="55"/>
                        </StackPanel>
                    </StackPanel>
                </ScrollViewer>
            </controls:PanoramaItem>
 
            <!--Panorama queue-->
            <!--Use 'Orientation="Horizontal"' to enable a panel that lays out horizontally-->
            <controls:PanoramaItem Header="queue">
                <ListBox Margin="0,0,-12,0" ItemsSource="{Binding RequestQueueList}" ItemContainerStyle="{StaticResource ListBoxItemStyleDisableSelection}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,17" VerticalAlignment="Top">
                                <Image Width="100" Height="100" Source="{Binding Track.AlbumArt, Converter={StaticResource imgConveter}}"
                                    VerticalAlignment="Top" Margin="0,7,0,0" />
                                <StackPanel Width="311">
                                    <HyperlinkButton FontSize="20" Style="{StaticResource HyperlinkButtonWrappingStyle}"
                                        HorizontalAlignment="Left"
                                        Content="{Binding Track.Album}" TargetName="_blank"
                                        NavigateUri="{Binding Track.AlbumUrl, Converter={StaticResource uriConverter}}"/>
                                    <TextBlock Text="{Binding Path=Track, Converter={StaticResource titleAndDurationConverter}}"
                                        Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>
                                    <Grid
                                        Background="#FF000044">
                                        <TextBlock Text="{Binding Path=., Converter={StaticResource requesterCommentConverter}}"
                                            Style="{StaticResource PhoneTextNormalStyle}" FontSize="{StaticResource PhoneFontSizeSmall}" TextWrapping="Wrap" />
                                    </Grid>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PanoramaItem>
            
            <!--Panorama chat-->
            <controls:PanoramaItem Header="chat" Height="510" VerticalAlignment="Top">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ListBox Margin="0,0,-12,0" Grid.Row="0"
                        ItemsSource="{Binding ChatList}" ItemContainerStyle="{StaticResource ListBoxItemStyleDisableSelection}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Width="411" Margin="0,0,0,10">
                                    <TextBlock Text="{Binding Author}" Margin="11,0,0,0" TextWrapping="Wrap"/>
                                    <ctb:ChatTextBlock
                                        TopLeftArrowVisibility="Visible"
                                        TimestampText="{Binding Timestamp}">
                                        <ctb:ChatTextBlock.Content>
                                            <TextBlock Text="{Binding Message}"
                                                Margin="11,8,10,0" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
                                        </ctb:ChatTextBlock.Content>
                                    </ctb:ChatTextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <ctb:ChatTextBlock
                        Grid.Row="1"
                        BottomRightArrowVisibility="Visible"
                        Margin="0,10,10,0"
                        TimestampVisibility="Collapsed"
                        Visibility="{Binding IsEnableChatSend, Converter={StaticResource visibilityConverter}}">
                        <ctb:ChatTextBlock.Content>
                            <TextBox x:Name="txtChatMessage" Text="" Width="400" BorderThickness="0" Padding="0">
                                <TextBox.InputScope>
                                    <InputScope>
                                        <InputScopeName NameValue="Text"/>
                                    </InputScope>
                                </TextBox.InputScope>
                            </TextBox>
                        </ctb:ChatTextBlock.Content>
                    </ctb:ChatTextBlock>
                </Grid>
            </controls:PanoramaItem>
            
            <!--Panorama thank you-->
            <controls:PanoramaItem Header="thank you">
                <StackPanel>
                    <Button x:Name="btnThankyou" BorderThickness="0" Padding="0" Margin="0" Width="300" Height="300"
                        Click="btnThankyou_Click">
                        <Image Source="/Resources/album_cover_default.png"/>
                    </Button>
                    <TextBlock Text="Tap above to visit SST" Style="{StaticResource PhoneTextSubtleStyle}" Margin="0,-15,0,0" HorizontalAlignment="Center" TextAlignment="Center"/>
                    <TextBlock Text="Thank you for accompanying me through the lonely nights" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center" Margin="0, 10, 0, 0"/>
                    <TextBlock Text="No rights reserved" HorizontalAlignment="Center" TextAlignment="Center" Margin="0, 20, 0, 0" />
                </StackPanel>
            </controls:PanoramaItem>
        </controls:Panorama>
        <Grid Margin="0,170,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Text="{Binding Message}"
            HorizontalAlignment="Center"/>
            <ProgressBar Grid.Row="1" Height="10" Visibility="{Binding IsDownloadIndicatorVisible, Converter={StaticResource visibilityConverter}}"
            IsIndeterminate="True" Foreground="White" IsEnabled="True" />
        </Grid>
        <MediaElement x:Name="player" AutoPlay="True"/>
    </Grid>
    <!--Panorama-based applications should not show an ApplicationBar-->
    <!--Sorry Microsft, i do not agree with you.-->
</phone:PhoneApplicationPage>